package cn.sofwin.day0201.homework;

import java.util.*;

public class t1 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("a");
        list.add("f");
        list.add("b");
        list.add("c");
        list.add("a");
        list.add("d");


       /* Set<String> set = new HashSet();
        set.addAll(list);



        list.clear();
        list.addAll(set);*/


        List<String> list2 = new ArrayList<>();
        for(String s:list){
            if(!contains(list2,s)){
                list2.add(s);
            }
        }
        list = list2;


        System.out.println("去重后的list：" + list);

    }

    public static boolean contains(List<String> o,String s) {
        boolean check = false;
        Iterator<String> it = o.iterator();
        while (it.hasNext()) {
            if (it.next().equals(s)) {
                check = true;
                break;
            }
        }
        return check;
    }
}
